package PenguinsFarm.Penguins
{
	import XMFramework.Interface.Architechture.SMModel;
	import XMFramework.Interface.IEventDispatcher;
	
	import flash.events.EventDispatcher;
	import flash.utils.Dictionary;

	public class PenguinsModel extends SMModel// implements IEventDispatcher
	{
		public static var ON_RESOURCE_DATA_UPDATE:String = "ON_RESOURCE_DATA_UPDATE";
		
		private var owner:PenguinsEntity;
		private var data:Object;
		private var dispatcher:EventDispatcher;
		
		public function PenguinsModel( owner:PenguinsEntity )
		{
			super();
			
			this.owner	=	owner;
			data		=	new Object();
		}
		
		public function onInit( configData:Dictionary, initData:Object ):void
		{
			
		}
		
		public function getData( dataName:String ):*
		{
			if( data.hasOwnProperty( dataName ) )
			{
				return data[dataName];
			}
			return null;
		}
		
		public function setData( dataName:String, value:* ):void
		{
			if( !data.hasOwnProperty(dataName) )
			{
				data[dataName] = value;
			}
		}
		
		public function increaseResourceData( dataName:String, amount:* ):void
		{
			if( data.hasOwnProperty( dataName ) )
			{
				data[dataName] += amount;
				// dispatch event increase resource data
			}
		}
		
		public function decreaseResourceData( dataName:String, amount:* ):void
		{
			if( data.hasOwnProperty( dataName ) )
			{
				data[dataName] -= amount;
				// dispatch event decrease resource data
			}
		}
	}
}